// CommandLineHelper Library
// =========================
// License: Microsoft Permissive License (Ms-PL) v1.1
// Author: Rhy Mednick (http://www.rhyverse.net)
// Project Site: http://www.codeplex.com/CommandLineHelper

using System;
using System.Collections.Generic;
using System.Text;

namespace CommandLineHelper.Attributes
{
    /// <summary>
    /// Identifies a property in a class as a command line parameter for the application.
    /// </summary>
    
    [AttributeUsage(AttributeTargets.Property, AllowMultiple=false, Inherited=false)]
    public sealed class ParameterAttribute : Attribute
    {
        #region Constructors
        /// <summary>
        /// Constructs a ParameterAttribute object that is used to describe how the associated 
        /// property is related to a command line parameter.
        /// </summary>
        public ParameterAttribute() : this(null, false, false) { }
        /// <summary>
        /// Constructs a ParameterAttribute object that is used to describe how the associated 
        /// property is related to a command line parameter.
        /// </summary>
        /// <param name="helpMessage">The message to display as a description for the associated property when the user asks for detailed help</param>
        public ParameterAttribute(string helpMessage) : this(helpMessage, false, false) { }
        /// <summary>
        /// Constructs a ParameterAttribute object that is used to describe how the associated 
        /// property is related to a command line parameter.
        /// </summary>
        /// <param name="mandatory">Flag indicating if the associated property is required</param>
        public ParameterAttribute(bool mandatory) : this(null, mandatory, false) { }
        /// <summary>
        /// Constructs a ParameterAttribute object that is used to describe how the associated 
        /// property is related to a command line parameter.
        /// </summary>
        /// <param name="helpMessage">The message to display as a description for the associated property when the user asks for detailed help</param>
        /// <param name="mandatory">Flag indicating if the associated property is required</param>
        public ParameterAttribute(string helpMessage, bool mandatory) : this(helpMessage, mandatory, false) { }
        /// <summary>
        /// Constructs a ParameterAttribute object that is used to describe how the associated 
        /// property is related to a command line parameter.
        /// </summary>
        /// <param name="helpMessage">The message to display as a description for the associated property when the user asks for detailed help</param>
        /// <param name="mandatory">Flag indicating if the associated property is required</param>
        /// <param name="valueFromRemainingArguments">Flag indicating if the associated property should contain all unassigned command line parameters</param>
        public ParameterAttribute(string helpMessage, bool mandatory, bool valueFromRemainingArguments)
        {
            _helpMessage = helpMessage;
            _mandatory = mandatory;
            _valueFromRemainingArguments = valueFromRemainingArguments;
        }
        #endregion Constructors

        #region Public Properties
        /// <summary>
        /// Gets or sets the message displayed when the user asks for detailed help on the command line.
        /// </summary>
        public string HelpMessage
        {
            get { return _helpMessage; }
            set { _helpMessage = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating if the command line parameter is mandatory.
        /// </summary>
        public bool Mandatory
        {
            get { return _mandatory; }
            set { _mandatory = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating if the property is to be used to hold all extra command line 
        /// arguments that don't have another property to be assigned to.
        /// </summary>
        public bool ValueFromRemainingArguments
        {
            get { return _valueFromRemainingArguments; }
            set { _valueFromRemainingArguments = value; }
        }
        #endregion Public Properties

        #region Private Fields
        private string _helpMessage;
        private bool _mandatory;
        private bool _valueFromRemainingArguments;
        #endregion Private Fields
    }
}
